//package com.example.myopencv.rxgrallery;
//
//import android.Manifest;
//import android.app.Activity;
//import android.content.Intent;
//import android.content.pm.PackageManager;
//import android.os.Build;
//import android.os.Bundle;
//import android.view.View;
//import android.widget.Button;
//import android.widget.Toast;
//
//import androidx.annotation.Nullable;
//
//import com.example.myopencv.R;
//import com.lzy.imagepicker.ImagePicker;
//import com.lzy.imagepicker.bean.ImageItem;
//import com.lzy.imagepicker.ui.ImageGridActivity;
//import com.lzy.imagepicker.view.CropImageView;
//
//import java.util.ArrayList;
//
//
//public class RxgalleryfinalActivity extends Activity {
//    Button camera;
//    Button photo;
//    Button More_photo;
//    Button tailor;
//    Button video;
//    @Override
//    protected void onCreate(@Nullable Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_rxgallery);
//        More_photo = findViewById(R.id.More_photo);
//        photo = findViewById(R.id.photo);
//        video = findViewById(R.id.video);
//        camera = findViewById(R.id.camera);
//        tailor = findViewById(R.id.tailor);
//        checkPermission();
//
//        ImagePicker imagePicker = ImagePicker.getInstance();
////        imagePicker.setImageLoader(new PicassoImageLoader());   //设置图片加载器
//        imagePicker.setShowCamera(true);  //显示拍照按钮
//        imagePicker.setCrop(true);        //允许裁剪（单选才有效）
//        imagePicker.setSaveRectangle(true); //是否按矩形区域保存
//        imagePicker.setSelectLimit(9);    //选中数量限制
//        imagePicker.setStyle(CropImageView.Style.RECTANGLE);  //裁剪框的形状
//        imagePicker.setFocusWidth(800);   //裁剪框的宽度。单位像素（圆形自动取宽高最小值）
//        imagePicker.setFocusHeight(800);  //裁剪框的高度。单位像素（圆形自动取宽高最小值）
//        imagePicker.setOutPutX(1000);//保存文件的宽度。单位像素
//        imagePicker.setOutPutY(1000);//保存文件的高度。单位像素
//        camera.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                figurePermission(1);
//
//            }
//        });
//        photo.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                figurePermission(2 );
//
//            }
//        });
//
//
//        More_photo.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                figurePermission(3);
//
//            }
//        });
//        tailor.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//               figurePermission(4);
//
//            }
//        });
//        tailor.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//               figurePermission(5);
//
//            }
//        });
//    }
//    public boolean checkPermission() {
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && checkSelfPermission(
//                Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
//            requestPermissions(new String[]{
//                    Manifest.permission.READ_EXTERNAL_STORAGE,
//                    Manifest.permission.WRITE_EXTERNAL_STORAGE,
//                    Manifest.permission.CAMERA
//            }, 1);
//
//        }
//        return false;
//    }
//    private static final int REQUEST_CODE_CHOOSE_PHOTO = 1;
//    private static final int REQUEST_CODE_TAKE_PHOTO = 2;
//    private static final int REQUEST_CODE_CROP = 3;
//    private void figurePermission(int type ) {
//
////        XXPermissions.with(this)
////                .permission(Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)
////                .request((permissions, all) -> {
////                    if (all) {
//                        switch (type){
//                            case 1:
//                                Intent intent2 = new Intent(this, ImageGridActivity.class);
//                                startActivityForResult(intent2, REQUEST_CODE_CHOOSE_PHOTO);
////                                RxGalleryFinalApi.openZKCamera(RxgalleryfinalActivity.this);
//                                break;
//                            case 2:
//                                Intent intent = new Intent(this, ImageGridActivity.class);
//                                intent.putExtra(ImageGridActivity.EXTRAS_TAKE_PICKERS,true); // 是否是直接打开相机
//                                startActivityForResult(intent, REQUEST_CODE_CHOOSE_PHOTO);
////                                RxGalleryFinalApi instance = RxGalleryFinalApi.getInstance(RxgalleryfinalActivity.this);
////
////                                RxGalleryFinalApi
////                                        .openRadioSelectImage(RxgalleryfinalActivity.this, new RxBusResultDisposable<ImageRadioResultEvent>() {
////                                            @Override
////                                            protected void onEvent(ImageRadioResultEvent o) throws Exception {
////                                                //显示图片地址
////                                                Toast.makeText(RxgalleryfinalActivity.this, "选择图片的路径" + o.getResult().getOriginalPath(), Toast.LENGTH_SHORT).show();
////                                            }
////                                        }, true);
//                                break;
//                            case 3:
////                                RxGalleryFinalApi
////                                        .getInstance(RxgalleryfinalActivity.this)
////                                        .setType(RxGalleryFinalApi.SelectRXType.TYPE_IMAGE, RxGalleryFinalApi.SelectRXType.TYPE_SELECT_MULTI)
////                                        .setImageMultipleResultEvent(new RxBusResultDisposable<ImageMultipleResultEvent>() {
////                                            @Override
////                                            protected void onEvent(ImageMultipleResultEvent imageMultipleResultEvent) throws Exception {
////                                                List<MediaBean> result = imageMultipleResultEvent.getResult();
////                                                for (int i = 0; i < result.size(); i++) {
////                                                    System.out.println("多选图片的回调" + result.get(i).getOriginalPath());
////                                                    Toast.makeText(RxgalleryfinalActivity.this, "多选图片的回调" + result.get(i).getOriginalPath(), Toast.LENGTH_SHORT).show();
////                                                }
////                                            }
////                                        }).open();
//                                break;
//                            case 4:
////                                RxGalleryFinalApi instance2 = RxGalleryFinalApi.getInstance(RxgalleryfinalActivity.this);
////                                instance2.openGalleryRadioImgDefault(
////                                                new RxBusResultDisposable<ImageRadioResultEvent>() {
////                                                    @Override
////                                                    protected void onEvent(ImageRadioResultEvent imageRadioResultEvent) throws Exception {
////                                                        Toast.makeText(RxgalleryfinalActivity.this, "只要选择图片地址" + imageRadioResultEvent.getResult().getOriginalPath(), Toast.LENGTH_SHORT).show();
////                                                    }
////                                                })
////                                        .onCropImageResult(
////                                                new IRadioImageCheckedListener() {
////                                                    @Override
////                                                    public void cropAfter(Object t) {
////                                                        Toast.makeText(RxgalleryfinalActivity.this, "裁剪完成" + t, Toast.LENGTH_SHORT).show();
////                                                    }
////
////                                                    @Override
////                                                    public boolean isActivityFinish() {
////                                                        //返回false不关闭，返回true则为关闭
////                                                        return true;
////                                                    }
////                                                });
//                                break;
//                            case 5:
//
//                                break;
//                        }
//
////                    }
////                });
//
//
//    }
//    @Override
//    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//        super.onActivityResult(requestCode, resultCode, data);
//        if (resultCode == ImagePicker.RESULT_CODE_ITEMS) {
//            if (data != null && requestCode == REQUEST_CODE_CHOOSE_PHOTO) {
//                ArrayList<ImageItem> images = (ArrayList<ImageItem>) data.getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS);
//              if(null!=images&&images.size()>0){
//                  video.setText(images.get(0).path);
//              }
//
//            } else {
//                Toast.makeText(this, "没有数据", Toast.LENGTH_SHORT).show();
//            }
//        }
//    }
////    @Override
////    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
////        super.onActivityResult(requestCode, resultCode, data);
////        System.out.println(requestCode);
////        System.out.println(resultCode);
////
////        if (requestCode == RxGalleryFinalApi.TAKE_IMAGE_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
////            Toast.makeText(this, "拍照后，图片路径:" + RxGalleryFinalApi.fileImagePath.getPath(), Toast.LENGTH_SHORT).show();
////        }
////
////
////    }
//}
